import java.util.Scanner;

public class GuessNumber {
    public static void game(){
        int num = (int) (Math.random()*100+1);
        Scanner scanner = new Scanner(System.in);
        for (int i =0; i<7;i++){
            System.out.println("请输入您猜测的数字：");
            int userNum = scanner.nextInt();
            if (num<userNum){
                System.out.println("您猜大了！");
            }else if (userNum<num){
                System.out.println("您猜小了！");
            }
            else {
                System.out.println("恭喜你！答对了！！！");
                break;
            }
        }
    }
    public static void main(String[] args) {
        while (true){
            System.out.println("想玩游戏？(y/n)");
            Scanner input = new Scanner(System.in);
            String s = input.next();
            if (s.equals("y")||s.equals("Y")){
                game();
            }else if (s.equals("N")||s.equals("n")){
                System.out.println("游戏结束！！！");
                break;
            }
        }
    }
}
